
//服务器接口地址
var server_url = "http://dz.qingbao.dzwww.com/yqgz/syj/api.php?";  //接口地址
 
 
/*
 * 本地存储函数的封装
 */
function Alpe_getLocalStorge(lsKey){
	var item = localStorage.getItem(lsKey);
	if(item=='' || item==null || typeof(item)=="undefined"){
		return '';
	}else{
		return item;
	}
}

/*
 * 本地存储函数的封装
 */
function Alpe_setLocalStorge(lsKey,lsValue){
	var item = localStorage.getItem(lsKey);
	if(item=='' || item==null || typeof(item)=="undefined"){
		localStorage.setItem(lsKey,lsValue);
	}else{
		localStorage.removeItem(lsKey); 
		localStorage.setItem(lsKey,lsValue);
	}
	return true;
}


/***
 * *获取联系电话接口 
 * * 如果返回空则直接写入
 * */

     function cntact_phone(){
          var url = server_url+'r=login/getQbTel&v=1.0';		  		    
		   api.ajax({
			      url: url,
			      method: 'get',
			      cache: false,
			      timeout: 30,			
			      dataType: 'json'
		    }, function(ret, err){  
			      if (ret) {//服务器成功返回数据，验证数据是否正确			  
			           document.getElementById("tel").innerHTML = '联系电话：<a href="tel:'+ret.tel+'">'+ret.tel+'</a>'; 
			      } 
		   });		 
    }
     

/***
 * *登录接口  成功后使用文本的方式保存返回的信息
 * *
 * *access_token  登录成功后返回的32位授权码
 * *admin_id      登录成功后返回的账号id
 * *username      登录的账号名称
 * *deviceId      设备唯一标识
 * *systemType    系统类型
 * */
     
    function login(username,password,deviceId,systemType){                		   
		   var url = server_url+'r=login/login&username='+username+'&password='+password+'&v=1.0&device_number='+deviceId+'&system_type='+systemType+'&jpush=notification';		  
		   api.showProgress({
                style: 'default',
                animationType: 'fade',
                title: '登录验证中...',
                text: '请稍后...',
                modal: false
           });
		   api.ajax({
			      url: url,
			      method: 'get',
			      cache: false,
			      timeout: 30,			
			      dataType: 'json'
		    }, function(ret, err){ 
			      if (ret) {//服务器成功返回数据，验证数据是否正确			  
			              if(ret.success == '000'){
			                     //验证正确，将相关信息写入文件保存 
			                     var json = {"access_token":ret.access_token,"admin_id":ret.admin_id,"username":username,"password":password};
	                                 api.writeFile({
                                         path: 'fs://yqgzpt.txt',
                                         data: $api.jsonToStr(json)//将json转成字符串保存到文本中
                                     });
		                     			                         
			                     //进入首页	
			                  
			                     api.openSlidLayout({
							          leftEdge:api.winWidth / 3.27,
							          type:'left',
							          fixedPane:{
							              name: 'leftMenu',
							              url: './html/leftMenu.html',
							              bounces: false,							              
				                          vScrollBarEnabled:false,
				                          scaleEnabled:true,
				                          hScrollBarEnabled:false,
				                     
						              },
						              slidPane:{
							              name: 'indexMain',
							              url: './html/indexMain.html',
							              bounces:false,							             
                                          vScrollBarEnabled:false,
                                          scaleEnabled:true,
                                          hScrollBarEnabled:false,
                                       
						              }					 
					              });
					              api.hideProgress();
                           }else{
                               api.alert({title:'错误提示',msg:ret.message});  
                           }
			        }else {
			               //没有成功递交到服务器，返回错误代码和信息
				           api.alert({msg:('错误码：'+err.code+'；错误信息：'+err.msg+'网络状态码：'+err.statusCode)});
				           api.hideProgress();
			        }
		   });
		   api.hideProgress();
    }
    
/***
 * *退出登录接口  成功后将文本中的access_token和admin_id清空并返回登陆页
 * *
 * *access_token  登录成功后返回的32位授权码
 * *admin_id      登录成功后返回的账号id
 * *username      登录的账号名称
 * *deviceId      设备唯一标识
 * *systemType    系统类型
 * */    
    
     function loginOut(){                      
         api.readFile({
             path:'fs://yqgzpt.txt'
         }, function(ret, err){           
             var data = eval('('+ret.data+')');
             var username = data.username; 
             var password = data.password;
             var admin_id = data.admin_id;
             var access_token = data.access_token;
             var sign = faultylabs.MD5(access_token+admin_id+'login/logout1.0syjqingbao');
                 sign = sign.toLowerCase();//将字符串大写转成小写
             var url = server_url+'r=login/logout&access_token='+access_token+'&admin_id='+admin_id+'&v=1.0&sign='+sign;                                  
             
            /********************执行ajax操作*********************************/
             api.ajax({
			      url: url,
			      method: 'get',
			      cache: false,
			      timeout: 30,			
			      dataType: 'json'
		     }, function(ret, err){
		          api.toast({
				       msg: ret.message,
                       duration:3000,
                       location: 'middle'
                  });
 
                  //操作成功，重新记录文本信息
			      if(ret.success == "010"){
			           var data = eval("({'username':'"+username+"','password':'"+password+"'})");
			           api.writeFile({
                            path: 'fs://yqgzpt.txt',
                            data: data
                       });
                       
                          //关闭主窗口回到登录窗口        
                          api.closeWin();
                          api.openWin({
                              name: 'index',
                              url: '../index.html',   
                              bounces:false,
                              vScrollBarEnabled:false,
                              hScrollBarEnabled:false
                          });
                    
                       
                   }	
			            
		      }); 
		       /********************执行ajax操作*********************************/
         });               
    
    }
/***  获取接口返回验证信息
 * *
 * ***/
    
    function get_sign(){
          api.readFile({
                 path:'fs://yqgzpt.txt'
            }, function(ret, err){           
                 var data = $api.strToJson(ret.data);  
                
                 document.getElementById("access_token").value = data.access_token; 
                 document.getElementById("admin_id").value = data.admin_id;                     
            });    
    }



/**
 * *列表分接口
 * *category  访问的页面名称或者是对应的接口
 * *operation 该页面的当前状态,刷新还是加载
 * *message_id  对应的专题ID
 * ***/
    function list(category,operation,message_id){
         switch(category){
                 case "mryq":
                 list_mryq(operation);//每日要情
                 break;
                 case "management":
                 countSort(operation);//舆情处置首先打开的是顶部菜单，然后加载列表数据
                 break;
                 case "collection":
                 list_collection();//我的收藏
                 break;
                 case "hot_spot":
                 list_rdzz();//我的收藏
                 break;
                 case "specialDynamic":
                 specialMenu(message_id);//热点追踪专题
                 break;
                 case "report":
                 Get_topmenu(category,operation);//舆情报告
                 break;
                 case "statistics":
                 Get_topmenu(category,operation);//数据统计
                 break;
                 case "classification":
                 Get_topmenu(category,operation);//数据统计
                 break;
                 default:
                 break;
         }
    }
    

 
/***修改密码
 * *
 * **/
    function change_password(old_password,new_password){//修改密码
            //如果验证值access_token不为空，执行ajax
            var access_token = $("#access_token").val();                     
		    var admin_id = $("#admin_id").val();  		 
		    var sign = faultylabs.MD5(access_token+admin_id+new_password+new_password+old_password+'user/editPassword1.0syjqingbao');
			    sign = sign.toLowerCase();//将字符串大写转成小写           
            var url = server_url+'r=user/editPassword&access_token='+access_token+'&admin_id='+admin_id+'&new_password='+new_password+'&new_password2='+new_password+'&old_password='+old_password+'&v=1.0&sign='+sign;            
                api.ajax({
			        url: url,
			        method: 'get',
			        cache: false,
			        timeout: 30,			
			        dataType: 'json'
		        }, function(ret, err){	                       
				        api.toast({
				             msg: ret.message,
                             duration:3000,
                             location: 'middle'
                        });
                        if(ret.success == "101"){
                            api.openWin({
                                name: 'index',
                                url: '../index.html',   
                                bounces:false,
                                vScrollBarEnabled:false,
                                hScrollBarEnabled:false
                            });
                        }
		        });    		                                         
    }


/***
 * *内容搜索列表
 * */
    function search_more(keywords){//搜索接口
            //如果验证值access_token不为空，执行ajax
           var access_token = $("#access_token").val();                     
		   var admin_id = $("#admin_id").val();  
		   var deal_status = "-1";
           var page=parseInt($("#pageIndex").val())+1;		              
		       $("#pageIndex").val(page);
           var sign = faultylabs.MD5(access_token+admin_id+deal_status+page+'datas/getMsglist'+keywords+'1.0syjqingbao');
               sign=sign.toLowerCase();//将字符串大写转成小写
           var url = server_url+'r=datas/getMsglist&access_token='+access_token+'&admin_id='+admin_id+'&deal_status='+deal_status+'&page='+page+'&v=1.0&search_str='+keywords+'&sign='+sign;
          
               api.ajax({
			        url: url,
			        method: 'get',
			        cache: false,
			        timeout: 30,			
			        dataType: 'json'
		       }, function(ret, err){
			        if (ret) { 
			              if(ret.success == '100'){  	
 				                  $.each(ret.msgdatalist, function (index, v) {			
 				                        var suggestion = v.suggestion.replace(/\n/g,"<br>");
				                            $("#list1").append('<div href="" class="Fix hightitem" onclick="openDetail('+v.message_id+')" tapmode="presshover"><div class="cnt"><div class="wrap"><div class="wrap2"><div class="content"><div class="shopname">'+v.title+'</div><div class="title">'+suggestion+'</div><div class="info"><span class="symbol">'+v.media_name+'</span><span class="price">'+v.send_time+'</span></div></div></div></div></div></div>');
				                  });
				                  api.hideProgress();
				          }else{
				                  api.toast({
				                       msg: ret.message,
                                       duration:3000,
                                       location: 'middle'
                                  }); 
                                  api.hideProgress();
				          }
			         }else{
			              api.toast({
				               msg: '数据请求错误，请检查网络链接状态或重新登录！',
                               duration:3000,
                               location: 'middle'
                          });
                          api.hideProgress();
			         }			                  
		       });        
    }
    
    
/**
 * *顶部导航菜单
 * *menu 需要顶部菜单的页面名称
 * **/
    function Get_topmenu(category,operation){ 
          //如果验证值access_token不为空，执行ajax
           var access_token = $("#access_token").val();                     
		   var admin_id = $("#admin_id").val();  		 
		   var sign = faultylabs.MD5(access_token+admin_id+'datas/GetMenu'+category+'1.0syjqingbao');
			   sign = sign.toLowerCase();//将字符串大写转成小写           
           var url = server_url+'r=datas/GetMenu&access_token='+access_token+'&admin_id='+admin_id+'&status='+category+'&v=1.0&sign='+sign;                                                         
               api.ajax({
			         url: url,
			         method: 'get',
			         cache: false,
			         timeout: 30,			
			         dataType: 'json'
		       }, function(ret, err){   
		             if(ret.success == '100'){ 
		                   //获取菜单对应的相关接口信息
		                   var menu_message = ret.menulist;
		                
						    // 顶部导航	 
						    var navigationBar = api.require("navigationBar");
							if("ios" == api.systemType && parseInt(api.systemVersion) >= 7){  
									y = "70";
							}else{ 
									y = "50";
							}  
							
							var status = $("#deal_status").val();									   		   	      
		                    var params = {
					               x: 0,
					               y: y,
					               h: 50,                
					               fixed:true,
					               selectedIndex:status,
					               items: ret.menulist,										 
					               font: {
						               size: 14,
						               sizeSelected: 16,
						               color: "#333",
						               colorSelected: "#000"
					                }
				            }; 
	                        function callback(ret, err){		                              	                      
					 	        	//判断当前访问是否切换菜单,如果切换则页码归零，列表清空
					 	            var status = $("#deal_status").val();									   
						            if(ret.index != status){ 
                                          $("#pageIndex").val(0);
                                          $("#main_content").html('');
                                          //输出当前菜单脚标
					 	                  $("#deal_status").val(ret.index);	
						             }
						            if(category == "report"){
						                list_report(menu_message[ret.index].remarks,operation);
						            }else if(category == "statistics"){
						                list_statistics(menu_message[ret.index].remarks,operation,menu_message[ret.index].id);//判断是否为报表id的参数
						            }else if(category == "classification"){
						                list_classification(menu_message[ret.index].id,operation);
						            }
					 	      			 	         
				            }		
				            navigationBar.open(params, callback);								 
					 }else{				 
						  api.toast({
								msg: ret.message,
								duration:2000,
								location: 'bottom'
						  });  
					 }
		              
		       });    		                                       
    }
    
/***分类列表
 * *
 * **/
    
    function list_classification(id,operation){//分类列表
           api.showProgress({
			    style: 'default',
			    animationType: 'fade',
			    title: '',
			    text: '',
			    modal: true
		   });
		   
		   //判断刷新还是加载
		   if(operation == "refresh"){
                $("#main_content").html('');
                $("#pageIndex").val(0);      
           } 
		   
		   //获取验证接口的值access_token、admin_id以及当前页码
           var access_token = $("#access_token").val();                     
           var admin_id = $("#admin_id").val(); 
           var page=parseInt($("#pageIndex").val())+1;		              
		       $("#pageIndex").val(page);
           
           //接口验证sign
           var sign = faultylabs.MD5(access_token+admin_id+'-1'+page+'datas/GetClassification'+id+'1.0syjqingbao');
               sign = sign.toLowerCase();//将字符串大写转成小写
           var url = server_url+'r=datas/GetClassification&deal_status=-1&status='+id+'&access_token='+access_token+'&admin_id='+admin_id+'&page='+page+'&v=1.0&sign='+sign;            
               
               api.ajax({
			        url: url,
			        method: 'get',
			        cache: false,
			        timeout: 30,			
			        dataType: 'json'
		       }, function(ret, err){  
			  		if(ret.success == '100'){  	 
 				           $.each(ret.msgdatalist, function (index, v) {	 				                        
 				                   var suggestion = v.suggestion.replace(/\n/g,"<br>"); 
 				                   var style = "#333";
 				                   if(v.is_read == 1){
 				                        style = "#919193";
 				                   }
				                   $("#main_content").append('<div  class="main_content" onclick="openDetail('+v.message_id+')" tapmode="presshover"><div class="cnt"><div class="wrap"><div class="wrap2"><div class="content"><div class="shopname" style="color:'+style+'">'+v.title+'</div><div class="suggestion">'+suggestion+'</div><div class="info"><a class="symbol">'+v.media_name+'</a><a class="price">'+v.send_time+'</a></div></div></div></div></div></div>');
				           });
				           if(ret.totalrows < 20){
				              $("#text").html('');
                              $("#text").append("已无更多数据");
				           }
				            api.hideProgress();
				    }else{				                                  
				           api.toast({
				                 msg: ret.message,
                                 duration:2000,
                                 location: 'bottom'
                           });
                            api.hideProgress();
                            $("#text").html('');
				    }		       
		        });    
    }



/***舆情报告接口
 * *
 * ****/
    function list_report(remarks,operation){
          api.showProgress({
			    style: 'default',
			    animationType: 'fade',
			    title: '',
			    text: '',
			    modal: true
		   });
		   
		   //判断刷新还是加载
		   if(operation == "refresh"){
                $("#main_content").html('');
                $("#pageIndex").val(0);      
           } 
		   
		   //获取验证接口的值access_token、admin_id以及当前页码
           var access_token = $("#access_token").val();                     
           var admin_id = $("#admin_id").val(); 
           var page=parseInt($("#pageIndex").val())+1;		              
		       $("#pageIndex").val(page);
           
           //接口验证sign
           var sign = faultylabs.MD5(access_token+admin_id+page+remarks+'1.0syjqingbao');
               sign = sign.toLowerCase();//将字符串大写转成小写
           var url = server_url+'r='+remarks+'&access_token='+access_token+'&admin_id='+admin_id+'&page='+page+'&v=1.0&sign='+sign;            
              api.ajax({
					url:url,
					method: 'get',
					cache: false,
					timeout: 30,			
					dataType: 'json'
			   }, function(ret, err){
					if (ret) { 
			             if(ret.success == '100'){  		
				               $.each(ret.list, function (index, v) {
				                      $("#main_content").append('<div class="main_content" style="padding:15px 0px;"><div class="shopname hot-title" style="padding-left:2%;width: 88%;" onclick="openDown(\''+v.message_id+'\')" tapmode="presshover">'+v.title+'</div><div class="right"><img src="../image/btn/right.png" /></div></div>');				   	                                             	                                            		     
				               });                     
				         }else{				 
				               api.toast({
				                      msg: ret.message,
                                      duration:2000,
                                      location: 'bottom'
                               }); 		                 
				         }
				         if(ret.totalrows < 20){
				                $("#text").html('');
                                $("#text").append("已无更多数据");
				         }
				          api.hideProgress();
			        }else{
			             api.toast({
				              msg: '数据请求错误，请检查网络链接状态或重新登录！',
                              duration:3000,
                              location: 'bottom'
                          });
                           api.hideProgress();
			        }
			  }); 	      
    }
    
/***
 * *数据统计接口
 * **/
    function list_statistics(remarks,operation,statistics_id){
           api.showProgress({
			    style: 'default',
			    animationType: 'fade',
			    title: '',
			    text: '',
			    modal: true
		   });
	
		   //判断刷新还是加载
		   if(operation == "refresh"){
                $("#main_content").html('');
                $("#pageIndex").val(0);      
           } 
		   
		   //获取验证接口的值access_token、admin_id以及当前页码
           var access_token = $("#access_token").val();                     
           var admin_id = $("#admin_id").val(); 
           var page=parseInt($("#pageIndex").val())+1;		              
		       $("#pageIndex").val(page);
           
           //接口验证sign
           var sign = faultylabs.MD5(access_token+admin_id+remarks+'1.0syjqingbao');
               sign=sign.toLowerCase();//将字符串大写转成小写
           var url = server_url+'r='+remarks+'&access_token='+access_token+'&admin_id='+admin_id+'&v=1.0&sign='+sign;                                 
               console.log(url);
               api.ajax({
					url:url,
					method: 'get',
					cache: false,
					timeout: 30,			
					dataType: 'json'
			   }, function(ret, err){ 
				     var x;
				     var y;				            
					 if (ret) { 
			                if(ret.success == '100'){//如果获取数据成功，现根据菜单id选择加载曲线和表格，然后将数值赋值
			                      if(ret.x == ''){			                            
			                           api.toast({
				                           msg: ret.message,
                                           duration:2000,
                                           location: 'middle'
                                        }); 		  			                                 
			                       }else{
			                            if(statistics_id == 100){//id为100默认是最后一个工作考核表格样式
				                               data = ret.list;
				                               list_statistics_table(data,ret.img);
				                         }else{//其他菜单赋值后输出曲线图         
				                         	if('datas/SmonitorDatas'==remarks){
		                                       list_statistics_line(ret.x,ret.y);
		                                   	}
				                         	else if('datas/SdealDatas'==remarks){
		                                    	list_statistics_line(ret.weeks_line.months_x,ret.weeks_line.months_y);
		                                    }
		                                    else if('datas/SkH'==remarks){
		                                    	list_statistics_line(ret.x,ret.y);
		                                    }
		                                    else if('datas/SareaDatas'==remarks){
		                                    	list_statistics_line(ret.city_list.x,ret.city_list.y);
		                                    }
		                                 }
				                    }
			                         api.hideProgress();
				              }else{				 
				                    api.toast({
				                         msg: ret.message,
                                         duration:2000,
                                         location: 'bottom'
                                     }); 
                                      api.hideProgress();
				               }
			           }else{
			                   api.toast({
				                     msg: '数据请求错误，请检查网络链接状态或重新登录！',
                                     duration:3000,
                                     location: 'bottom'
                                }); 
                                 api.hideProgress();
			            }			                 
				}); 
		    
 
    }
    
/***数据统计报表
 * *
 * **/
	function gotoShowPicFun(pic){
		if('ios'==api.systemType){
        	api.openApp({
			    iosUrl: pic
			},function(ret,err){
			     
			});
        }
        if('android'==api.systemType){
        	api.openApp({
			    androidPkg: 'android.intent.action.VIEW',
			    
			    uri: pic
			},function(ret,err){ 
			});
        }	    
	}
    function list_statistics_table(type,imgList){
        $("#main_content").html('');
        document.getElementById('main_content').style.width = '100%';
         var html = '<table width="90%" align="center" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000"><tr align="center"><td>地市</td><td>未处置<br />(百分比)</td><td>处置中<br />(百分比)</td><td>处置完成<br />(百分比)</td><td>总量</td></tr>';
         $.each(type, function (key, value){
	           html += '<tr><td>'+value.city_name+'</td><td>'+value.count[0][0]+'%</td><td>'+value.count[1][0]+'%</td><td>'+value.count[2][0]+'%</td><td>'+value.num+'</td></tr>';	
		 });
		 html +='</table>';
		 for (img in imgList){
		 
		 	html +='<br/>';
		 	html+="<a onclick=gotoShowPicFun('"+imgList[img]+"')><img src='"+imgList[img]+"' style='width:98%' /> </a>"; 
		}
		 
		  
	     
	     $("#main_content").append(html);		         
    }


/***数据统计曲线图
 * *
 * **/
    function list_statistics_line(x,y){
      
      var persons = x.persons;
      var number = eval(x).length;
      var min_number = 6;
      var max_number = 12;
      document.getElementById('main_content').style.height = '400px'; 
      if(number < 4){
          document.getElementById('main_content').style.width = '100%';      
      }else if(number > 4 && number < 12){
          document.getElementById('main_content').style.width = '140%';
        
      }else if(number > 12){
          document.getElementById('main_content').style.width = '200%';
      } 
 
     var myChart = echarts.init(document.getElementById('main_content'));
         api.showProgress({
			        style: 'default',
			        animationType: 'fade',
			        title: '',
			        text: '',
			        modal: true
			     });
        myChart.setOption({
            tooltip : {
                trigger: 'axis'
            },
             toolbox: {
                show : true,
                feature : {
                    
                    magicType : {show: true, type: ['line', 'bar']},
                    
                }
            }, 
            xAxis : [
                {
                    type : 'category',
                    data : x
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    splitArea : {show : true}
                }
            ],
            series : [
                {
                    name:'条数',
                    type:'bar',
                    data:y
                }
            ]
        });
         api.hideProgress();
         $("#text").html('');
    }    
     
/**
 **每日要情接口 
 **
 * */
 
    function list_mryq(operation){//每日要情数据
           api.showProgress({
			    style: 'default',
			    animationType: 'fade',
			    title: '',
			    text: '',
			    modal: true
		   });
		   
		   //判断刷新还是加载
		    if(operation == "refresh"){
              $("#main_content").html('');
              $("#pageIndex").val(0);      
            } 
		   
		   //获取验证接口的值access_token、admin_id以及当前页码
           var access_token = $("#access_token").val();                     
           var admin_id = $("#admin_id").val(); 
           var page=parseInt($("#pageIndex").val())+1;		              
		       $("#pageIndex").val(page);
           
           //接口验证sign
           var sign = faultylabs.MD5(access_token+admin_id+page+'datas/getDaily1.0syjqingbao');
               sign = sign.toLowerCase();//将字符串大写转成小写
           
           //ajax接口地址
           var url = server_url+'r=datas/getDaily&access_token='+access_token+'&admin_id='+admin_id+'&page='+page+'&v=1.0&sign='+sign;
               api.ajax({
			         url: url,
			         method: 'get',
			         cache: false,
			         timeout: 30,			
			         dataType: 'json'
		       }, function(ret, err){
			         if (ret) {			                 			                        
			              var next = parseInt(ret.page)+parseInt(1);
			              if(ret.success == '100'){  		
				                $.each(ret.dailymsg, function (index, v) {
				                      var html = '<div class="home-tuan-list" id="list_content"><div class="item hightitem" style="text-align:center; padding-top:10px; font-size: 1.4em; font-weight: bold";>'+v.days+'</div>';	                         	                                 
	                                  $.each(v.list, function (key, value){
	                                           //定义下划线div的class
	                                            html += '<div class="item Fix hightitem"><div class="cnt"><div class="wrap"><div class="wrap2"><div class="content"><div class="shopname hot-title">'+value.title+'</div><div class="title hot-subtitle">'+value.abstract_content+'</div><div class="img"></div><div class="info" style="border-bottom: 1px solid #919193;padding-bottom:20px;" onclick="openDetail(\''+value.url+'\')" tapmode="presshover">'+value.url+'</div></div></div></div></div></div>';	
				                      });
	                                  html +='</div><div class="h20"></div>';
	                                  $("#main_content").append(html);			     
				                 }); 
				                  //如果返回信息少于20条,则在底部显示没有更多数据
				                  if(ret.totalrows < 20){
				                        $("#text").html('');
                                        $("#text").append("已无更多数据");
				                  }
				            }else{				 
				                 api.toast({
				                       msg: ret.message,
                                       duration:2000,
                                       location: 'middle'
                                  });         
				             }
			           } 
		        });
		   api.hideProgress();		       
    }  
 
/**
 * *舆情处置入口信息
 * *顶部菜单分类数据接口
 * */
    
	function countSort(operation){//处置信息数
	         if(operation == "refresh"){
	              $("#main_content").html('');
	              $("#pageIndex").val(0);
	              api.execScript({
					    name: 'indexMain',
					    script: 'get_number();'
				  });
	         }             
	         var status = $("#deal_status").val();
	         
	
			//获取验证接口的值access_token、admin_id以及当前页码
			var access_token = $("#access_token").val();                     
			var admin_id = $("#admin_id").val();              
			var sign = faultylabs.MD5(access_token+admin_id+'datas/infoTotal1.0syjqingbao');
				sign = sign.toLowerCase();//将字符串大写转成小写
			var url = server_url+'r=datas/infoTotal&access_token='+access_token+'&admin_id='+admin_id+'&v=1.0&sign='+sign;
				api.ajax({
					 url: url,
					 method: 'get',
					 cache: false,
					 timeout: 30,			
					 dataType: 'json'
				 }, function(ret, err){
				 	 
						   if(ret.success == '100'){  
						         if(operation == "indexMain"){
						              $("#number").html(ret.list[0]);
						         }else{
									  // 顶部导航	 
									  var navigationBar = api.require("navigationBar");
											  if("ios" == api.systemType && parseInt(api.systemVersion) >= 7){  
												  y = "70";
											  }else{ 
												  y = "50";
											  }        
									  var params = {
											  x: 0,
											  y: y,
											  h: 50,                
											  fixed:true,
											  selectedIndex:status,
											  items: [{title:"未处置("+ret.list[0]+")",titleSelected:"未处置("+ret.list[0]+")",bg:"#D4D3D3",alpha: 0.8,bgSelected:"#B8B8B8"},{title:"处置中("+ret.list[1]+")",titleSelected:"处置中("+ret.list[1]+")",bg:"#D4D3D3",alpha: 0.8,bgSelected:"#B8B8B8"},{title:"处置完毕("+ret.list[2]+")",titleSelected:"处置完毕("+ret.list[2]+")",bg:"#D4D3D3",alpha: 0.8,bgSelected:"#B8B8B8"}],						
										 
											  font: {
													size: 14,
													sizeSelected: 16,
													color: "#333",
													colorSelected: "#000"
											   }
										}; 
		
										function callback(ret, err){										    																					 
												var status = $("#deal_status").val();									   
												if(ret.index != status){ var type = 1;}//判断当前显示内容是否为即将访问的内容,如果切换了菜单则type=1
												$("#deal_status").val(ret.index);			                                   
												list_yqcz(ret.index,type) 																 
										 }		
										 navigationBar.open(params, callback);
									 }
						   }else{				 
									 api.toast({
										  msg: ret.message,
										  duration:2000,
										  location: 'bottom'
									  });  
						   }
			     });    
	}



	
	
/**
 * *舆情处置列表信息
 * *
 * **/
    function list_yqcz(deal_status,type){//舆情处置列表数据          
        
         api.showProgress({
			   style: 'default',
			   animationType: 'fade',
			   title: '',
			   text: '',
			   modal: true
		 });
         //获取验证接口的值access_token、admin_id以及当前页码
	     var access_token = $("#access_token").val();                     
		 var admin_id = $("#admin_id").val();              
		 
         
         //如果切换了菜单，全部清除
         if(type == 1){
             $("#pageIndex").val(0);
             $("#main_content").html('');
         }
          var page=parseInt($("#pageIndex").val())+1;		              
		      $("#pageIndex").val(page);
         var sign = faultylabs.MD5(access_token+admin_id+deal_status+page+'datas/getMsglist1.0syjqingbao');
			 sign = sign.toLowerCase();//将字符串大写转成小写
         var url = server_url+'r=datas/getMsglist&access_token='+access_token+'&admin_id='+admin_id+'&deal_status='+deal_status+'&page='+page+'&v=1.0&sign='+sign;            
 			console.log(url);
             api.ajax({
			      url: url,
			      method: 'get',
			      cache: false,
			      timeout: 30,			
			      dataType: 'json'
		     }, function(ret, err){                    			                   
				  if(ret.success == '100'){  
				       	
 				        $.each(ret.msgdatalist, function (index, v) {	
 				              var suggestion = v.suggestion.replace(/\n/g,"<br>");
 				              var style = "#333";
 				              if(v.is_read == 1){
 				                   style = "#919193";
 				              }
				              $("#main_content").append('<div  class="main_content" onclick="openDetail('+v.message_id+')" tapmode="presshover"><div class="cnt"><div class="wrap"><div class="wrap2"><div class="content"><div class="shopname" style="color:'+style+';">'+v.title+'</div><div class="suggestion">'+suggestion+'</div><div class="info"><a class="symbol">'+v.media_name+'</a><a class="price">'+v.send_time+'</a></div></div></div></div></div></div>');
				        });	
				        //如果返回信息少于20条,则在底部显示没有更多数据
				         if(ret.msgdatalist.length < 20){
				              $("#text").html('');
                              $("#text").append("已无更多数据");
				         }
				        api.hideProgress();
				   }else if(ret.success == '102'){
				   		api.hideProgress(); 
                        $("#text").html("已无更多数据");
				   }else{
				        api.toast({
				            msg: ret.message,
                            duration:2000,
                            location: 'bottom'
                         }); 
                         $("#text").html("已无更多数据");
                          api.hideProgress();
				   }			              			                  
		     });    		                              
    }
    
/***热点追踪专题列表
 * *
 * **/
    function list_rdzz(operation){//专题列表
         if(operation == "refresh"){
              $("#main_content").html('');
              $("#pageIndex").val(0);             
         } 
         api.showProgress({
			   style: 'default',
			   animationType: 'fade',
			   title: '',
			   text: '',
			   modal: true
		 });
         //获取验证接口的值access_token、admin_id以及当前页码
	     var access_token = $("#access_token").val();                     
		 var admin_id = $("#admin_id").val();              
		 
          var page=parseInt($("#pageIndex").val())+1;		              
		      $("#pageIndex").val(page);
         var sign = faultylabs.MD5(access_token+admin_id+page+'datas/GetSpecialList1.0syjqingbao');
			 sign = sign.toLowerCase();//将字符串大写转成小写
         var url = server_url+'r=datas/GetSpecialList&access_token='+access_token+'&admin_id='+admin_id+'&page='+page+'&v=1.0&sign='+sign;            
             api.ajax({
			      url: url,
			      method: 'get',
			      cache: false,
			      timeout: 30,			
			      dataType: 'json'
		     }, function(ret, err){
			      if (ret) {		  
						if(ret.success == '100'){  	
								//如果返回信息少于20条,则在底部显示没有更多数据
					         if(ret.totalrows < 20){
					              $("#text").html('');
	                              $("#text").append("已无更多数据");
					         }
 				               $.each(ret.list, function (index, v) {				       
				                     $("#main_content").append('<div  class="main_content" onclick="openSpecial('+v.id+',\''+v.name+'\')" tapmode="presshover"><div class="cnt"><div class="wrap"><div class="wrap2"><div class="content"><div class="shopname">'+v.name+'</div><span class="distance">('+v.count+')</span><div class="info"><a class="symbol">'+v.add_time+'</a><a style="background:red;color:#fff;padding:5px 15px;" class="price">专题</a></div></div></div></div></div></div>');
				               });				                          
				        }else{
				               api.toast({
				                     msg: ret.message,
                                     duration:3000,
                                     location: 'bottom'
                               });  
                               //如果返回信息少于20条,则在底部显示没有更多数据
					         if(ret.totalrows < 20){
					              $("#text").html('');
	                              $("#text").append("已无更多数据");
					         }
				         }
				         api.hideProgress();
				  }else{
					     api.toast({
				               msg: '数据请求错误，请检查网络链接状态或重新登录！',
                               duration:3000,
                               location: 'bottom'
                        }); 
                        api.hideProgress();
				  }					          
		    });    
		   
         
    }
    
/***
 * *热点追踪专题入口
 * ***/
	
	function specialMenu(special_id,operation){
	       // 顶部导航	 
		  var navigationBar = api.require("navigationBar");
			  if("ios" == api.systemType && parseInt(api.systemVersion) >= 7){  
					y = "70";
			  }else{ 
					y = "50";
			  } 
			  
		  //判断当前访问的菜单
		  var status = $("#deal_status").val();									   		   
	      
		  var params = {
					x: 0,
					y: y,
					h: 50,                
					fixed:true,
					selectedIndex:status,
					items: [{title:"最新动态",titleSelected:"最新动态",bg:"#D4D3D3",alpha: 0.8,bgSelected:"#B8B8B8"},{title:"热点互动",titleSelected:"热点互动",bg:"#D4D3D3",alpha: 0.8,bgSelected:"#B8B8B8"}],						
				 
					font: {
						size: 14,
						sizeSelected: 16,
						color: "#333",
						colorSelected: "#000"
					}
				}; 
	            function callback(ret, err){								    																					 
					 	if(ret.index == "0"){	
					 	   //关闭底部输入框
					 	   var obj = api.require('inputField');
                              obj.close(function(ret,err){});
					 	   //判断当前访问是否切换菜单,如果切换则页码归零，列表清空
					 	   var status = $("#deal_status").val();									   
						   if(ret.index != status){ 
                                $("#pageIndex").val(0);
                                $("#main_content").html('');
                                //输出当前菜单脚标
					 	        $("#deal_status").val(ret.index);	
						   }
					 	   specialDynamic(special_id);
					 	}else if(ret.index == "1"){
					 	  
					 	   //判断当前访问是否切换菜单,如果切换则页码归零，列表清空
					 	   var status = $("#deal_status").val();									   
						   if(ret.index != status){
                                $("#pageIndex").val(0);
                                $("#main_content").html('');
                                 //输出当前菜单脚标
					 	        $("#deal_status").val(ret.index);	
						   }
					 	  department_linkage(special_id);
					 	}
				}		
				navigationBar.open(params, callback);	          
    }

/***专题动态列表
 * *
 * **/
    function specialDynamic(special_id){ 
         
         api.showProgress({
			   style: 'default',
			   animationType: 'fade',
			   title: '',
			   text: '',
			   modal: true
		 });
         //获取验证接口的值access_token、admin_id以及当前页码
	     var access_token = $("#access_token").val();                     
		 var admin_id = $("#admin_id").val();              		 
         var page=parseInt($("#pageIndex").val())+1;		              
		     $("#pageIndex").val(page);
         var sign = faultylabs.MD5(access_token+admin_id+page+'datas/GetSpecialMsglist'+special_id+'1.0syjqingbao');
			 sign = sign.toLowerCase();//将字符串大写转成小写
         var url = server_url+'r=datas/GetSpecialMsglist&special_id='+special_id+'&access_token='+access_token+'&admin_id='+admin_id+'&page='+page+'&v=1.0&sign='+sign;                           
            
            api.ajax({
			     url: url,
			     method: 'get',
			     cache: false,
			     timeout: 30,			
			     dataType: 'json'
		     }, function(ret, err){
			     if (ret) { 		   						         				 
				      if(ret.success == '100'){  
				             
 				             $.each(ret.list, function (index, v) {				       
				                      $("#main_content").append('<div class="main_content" onclick="openDetail('+v.message_id+')" tapmode="presshover"><div class="cnt"><div class="wrap"><div class="wrap2"><div class="content"><div class="shopname">'+v.title+'</div><div class="info"><span class="symbol">'+v.media_name+'</span><span class="price">'+v.send_time+'</span></div></div></div></div></div></div>');
				             });				                          
				      }else{
				             api.toast({
				                   msg: ret.message,
                                   duration:3000,
                                   location: 'middle'
                             });          
                      }				
				  }else {						           
                      api.toast({
				             msg: '数据请求错误，请检查网络链接状态或重新登录！',
                             duration:3000,
                             location: 'bottom'
                      });  
				  }
				  api.hideProgress();
			}); 
    }
    
/***专题部门联动列表
 * *
 * ****/
    function department_linkage(special_id){
         //底部提交框    
         var obj = api.require('inputField');
             obj.open({
                  bgColor:'#f0f0f0',
                  lineColor:'#333',
                  fileBgColor:'#fff',
                  borderColor:'#908d8d',
                  placeholder:'请输入内容！',
                  sendImg:'widget://image/btn/submit.png'
            },function(ret,err) {
                  if(ret.msg){
                     submit_linkage(special_id,ret.msg);
                  }else{
                     api.alert({msg:"内容不能为空!"});
                  }
            }); 
    
          api.showProgress({
			   style: 'default',
			   animationType: 'fade',
			   title: '',
			   text: '',
			   modal: true
		 });
         //获取验证接口的值access_token、admin_id以及当前页码
	     var access_token = $("#access_token").val();                     
		 var admin_id = $("#admin_id").val();              		 
         var page=parseInt($("#pageIndex").val())+1;		              
		     $("#pageIndex").val(page);
         var sign = faultylabs.MD5(access_token+admin_id+page+'datas/GetSpecialMsgInfo'+special_id+'1.0syjqingbao');
			 sign = sign.toLowerCase();//将字符串大写转成小写
         var url = server_url+'r=datas/GetSpecialMsgInfo&special_id='+special_id+'&access_token='+access_token+'&admin_id='+admin_id+'&page='+page+'&v=1.0&sign='+sign;                
             
             api.ajax({
			      url: url,
			      method: 'get',
			      cache: false,
			      timeout: 30,			
			      dataType: 'json'
		      }, function(ret, err){
			      if (ret) { 	       						         				 
				       if(ret.success == '100'){  				                        
 				              $.each(ret.list, function (index, v) {				       
				                    $("#main_content").append('<div class="main_content"><div class="cnt"><div class="wrap"><div class="wrap2"><div class="content"><div class="shopname">'+v.content+'</div><div class="info"><span class="symbol">'+v.username+'</span><span class="price">'+v.inputtime+'</span></div></div></div></div></div></div>');
				              });				                          
				        } 
                           api.hideProgress();
				  } 				        
			 });           
    }
    
/***部门联动信息提交
 * *
 * **/
    //联动信息提交
    function submit_linkage(special_id,message){  
             //获取验证接口的值access_token、admin_id以及当前页码
	         var access_token = $("#access_token").val();                     
		     var admin_id = $("#admin_id").val();              		 
             var page=parseInt($("#pageIndex").val())+1;		              
		         $("#pageIndex").val(page);
             var sign = faultylabs.MD5(access_token+admin_id+message+'datas/GetSpecialSubmitMsg'+special_id+'1.0syjqingbao');
                 sign=sign.toLowerCase();//将字符串大写转成小写                      
             var url = server_url+'r=datas/GetSpecialSubmitMsg&message='+message+'&special_id='+special_id+'&access_token='+access_token+'&admin_id='+admin_id+'&v=1.0&sign='+sign;
                 api.ajax({
			           url: url,
			           method: 'get',
			           cache: false,
			           timeout: 30,			
			           dataType: 'json'
		         }, function(ret, err){
			           api.toast({
				             msg: ret.message,
                             duration:3000,
                             location: 'bottom'
                        });                                        					
				 });				                
    }
    
/**
 * *我的收藏列表
 * *
 * **/
    function list_collection(deal_status){//我的收藏
         if(deal_status == "refresh"){
              $("#list_content").html('');
              $("#pageIndex").val(0);
         }
         api.showProgress({
			   style: 'default',
			   animationType: 'fade',
			   title: '',
			   text: '',
			   modal: true
		 });
         //获取验证接口的值access_token、admin_id以及当前页码
	     var access_token = $("#access_token").val();                     
		 var admin_id = $("#admin_id").val();              
		 
         var page = parseInt($("#pageIndex").val())+1;	
             $("#pageIndex").val(page);
         var sign = faultylabs.MD5(access_token+admin_id+page+'datas/getCollect1.0syjqingbao');
			 sign = sign.toLowerCase();//将字符串大写转成小写
         var url = server_url+'r=datas/getCollect&access_token='+access_token+'&admin_id='+admin_id+'&page='+page+'&v=1.0&sign='+sign;                
    
            api.ajax({
			       url: url,
			       method: 'get',
			       cache: false,
			       timeout: 30,			
			       dataType: 'json'
		      }, function(ret, err){
		         
			      if(ret.success == '100'){  				                        
 				         $.each(ret.collectlist, function (index, v) {	 			       
				                var suggestion = v.suggestion.replace(/\n/g,"<br>");
				                var style = "#333";
 				                     if(v.is_read == 1){
 				                        style = "#919193";
 				                     }
 				                     $("#main_content").append('<div  class="main_content" onclick="openDetail('+v.message_id+')" tapmode="presshover"><div class="cnt"><div class="wrap"><div class="wrap2"><div class="content"><div class="shopname" style="color:'+style+'">'+v.title+'</div><div class="suggestion">'+suggestion+'</div><div class="info"><a class="symbol">'+v.media_name+'</a><a class="price">'+v.send_time+'</a></div></div></div></div></div></div>');
				         });
				         
				         //如果返回信息少于20条,则在底部显示没有更多数据
				         if(ret.totalrows < 20){
				              $("#text").html('');
                              $("#text").append("已无更多数据");
				         }
				         api.hideProgress();
				  }else{
				         api.toast({
				               msg: ret.message,
                               duration:3000,
                               location: 'middle'
                         });  
                         api.hideProgress();
                  }									        
			 });				                   
    }
	
/**
 * *舆情处置内容页
 * *message_id  文章id
 * **/
     function show(message_id){//舆情处置列表数据
             api.showProgress({
			      style: 'default',
			      animationType: 'fade',
			      title: '',
			      text: '',
			      modal: true
			 });
           
            //获取验证接口的值access_token、admin_id以及当前页码
	        var access_token = $("#access_token").val();                     
		    var admin_id = $("#admin_id").val();  
		    var sign = faultylabs.MD5(access_token+admin_id+message_id+'datas/getMsg1.0syjqingbao');
			    sign = sign.toLowerCase();//将字符串大写转成小写
            var url = server_url+'r=datas/getMsg&access_token='+access_token+'&admin_id='+admin_id+'&message_id='+message_id+'&v=1.0&sign='+sign;                            
            
               api.ajax({
			          url: url,
			          method: 'get',
			          cache: false,
			          timeout: 30,			
			          dataType: 'json'
		        }, function(ret, err){ 
		              if (ret) {   	                  
		                 
						       document.getElementById("listtitle").innerHTML = ret.title;
						       document.getElementById("from").innerHTML = ret.media_name
						       document.getElementById("date").innerHTML = ret.send_time;//发送时间
						       document.getElementById("url").innerHTML = '<div onclick="openDetail(\''+ret.url+'\')" tapmode="presshover" style="color:blue">'+ret.url+'</div>';
						       document.getElementById("content").innerHTML = ret.content;				                
						       document.getElementById("description").innerHTML = ret.abstract_content;
						       document.getElementById("remarks").innerHTML = ret.bak;
						       document.getElementById("contact").innerHTML = '<a href="tel:'+ret.tel+'" style="color:blue">'+ret.qb_tel+'</a>';
					     
					       
		              }else{
			               api.toast({
				                  msg: '数据请求错误，请重新登录！',
                                  duration:3000,
                                  location: 'bottom'
                            }); 
			            }
 			              api.hideProgress(); 
		         });    		                           
    }
     
     
/**
 * *舆情处置内容页底部菜单按钮
 * *message_id  文章id
 * **/
     function bottom_memu(message_id){//舆情处置列表数据
            
            //获取验证接口的值access_token、admin_id以及当前页码
	        var access_token = $("#access_token").val();                     
		    var admin_id = $("#admin_id").val();  
		    var sign = faultylabs.MD5(access_token+admin_id+message_id+'datas/getMsg1.0syjqingbao');
			    sign = sign.toLowerCase();//将字符串大写转成小写
            var url = server_url+'r=datas/getMsg&access_token='+access_token+'&admin_id='+admin_id+'&message_id='+message_id+'&v=1.0&sign='+sign;                            
                api.ajax({
			          url: url,
			          method: 'get',
			          cache: false,
			          timeout: 30,			
			          dataType: 'json'
		        }, function(ret, err){ 
		              if (ret) {   	                  
		                		document.getElementById("forwarding_status").value = ret.forwarding_status; 
					           if(ret.is_deal == 1){
					                document.getElementById("cz").innerHTML = '<img src="../image/btn/management.png" height="46">';
					                document.getElementById("wx").innerHTML = '<img src="../image/btn/invalid.png" height="46">';
					           }else{
					                document.getElementById("cz").innerHTML = '<img src="../image/btn/kong2.png" height="46">';
					                document.getElementById("wx").innerHTML = '<img src="../image/btn/kong2.png" height="46">';
					           }
					           if(ret.is_collect == "未收藏"){
					                var img = "collected.png";
					           }else{
					                var img = "already_collected.png";
					           }
					           document.getElementById("sc").innerHTML = '<img src="../image/btn/'+img+'" height="46">';
					           document.getElementById("fx").innerHTML = '<img src="../image/btn/share.png" height="46">';
					           //分享信息
					           document.getElementById("url").value = ret.detail_url;//地址
					           document.getElementById("title").value = ret.title;//标题
					           document.getElementById("abstract_content").value = ret.abstract_content;//摘要
					           
					           //文章信息
					           document.getElementById("message_id").value = message_id;//文章id
					           document.getElementById("is_collect").value = ret.is_collect;//已收藏或者未收藏
					           document.getElementById("is_pass").value = ret.is_pass;//0可以申请无效，1已申请无效
					           document.getElementById("pass_status").value = ret.pass_status;//0审核中，1通过，2不通过
					           document.getElementById("deal_status").value = ret.deal_status;//当前处置状态，0未处置，1处置中，2处置完毕
					    					       
		              }
		         });    		                           
    }     
 


/**
 * *添加收藏
 * *message_id  文章id
 * **/
    function collect(message_id){
           //如果验证值access_token不为空，执行ajax
           var access_token = $("#access_token").val();                     
		   var admin_id = $("#admin_id").val();  
		    
		   var sign = faultylabs.MD5(access_token+admin_id+message_id+'datas/setCollect1.0syjqingbao');
			   sign = sign.toLowerCase();//将字符串大写转成小写               
           var url = server_url+'r=datas/setCollect&access_token='+access_token+'&admin_id='+admin_id+'&message_id='+message_id+'&v=1.0&sign='+sign;            
               api.ajax({
			         url: url,
			         method: 'get',
			         cache: false,
			         timeout: 30,			
			         dataType: 'json'
		       }, function(ret, err){
		             if(ret.success == "101"){
		                 var is_collect = $("#is_collect").val();
		                 
                         if(is_collect == "未收藏"){
					          var img = "already_collected.png";
					          $("#is_collect").val("已收藏");  
					          
					     }else{
					          var img = "collected.png";
					          $("#is_collect").val("未收藏"); 					          
					     }
					     document.getElementById("sc").innerHTML = '<img src="../image/btn/'+img+'" height="46">';
                     }
		             api.toast({
				         msg: ret.message,
                         duration:2000,
                         location: 'middle'
                     });
                    
               });		       
    }
    
/***
 * *舆情处置信息提交功能
 * *
 * **/ 
    function yqcz_message(message_id,deal_status,measures,feedback,is_media,isreal,area){//对信息进行处置
               //如果验证值access_token不为空，执行ajax
               var access_token = $("#access_token").val();                     
		       var admin_id = $("#admin_id").val();  		                     
               var sign = faultylabs.MD5(access_token+admin_id+deal_status+feedback+is_media+isreal+measures+message_id+'datas/setDeal1.0syjqingbao');
                   sign=sign.toLowerCase();//将字符串大写转成小写
               var url = server_url+'r=datas/setDeal&feedback='+feedback+'&area_id='+area+'&isreal='+isreal+'&is_media='+is_media+'&message_id='+message_id+'&deal_status='+deal_status+'&measures='+measures+'&deal_result='+measures+'&access_token='+access_token+'&admin_id='+admin_id+'&v=1.0&sign='+sign;                
                   api.ajax({
			            url: url,
			            method: 'get',
			            cache: false,
			            timeout: 30,			
			            dataType: 'json'
		           }, function(ret, err){ 
		                api.toast({
				            msg: ret.message,
                            duration:2000,
                            location: 'middle'
                        }); 
                        if(ret.success == "101"){
                            if(deal_status == 1){
                                setTimeout(function(){api.closeWin({name:'disposalWin'});},1000);                                                       
                            }else if(deal_status == 2){
                                setTimeout(function(){api.closeWin({name:'disposaloverWin'});},1000);                              
                            }
                        } 
		           });		   		 
    }
    
/**
 * *信息标无效处理
 * *
 * **/
    function pass(message_id){//标记无效
           //如果验证值access_token不为空，执行ajax
           var access_token = $("#access_token").val();                     
		   var admin_id = $("#admin_id").val();  
		    
		   var sign = faultylabs.MD5(access_token+admin_id+message_id+'datas/setPass1.0syjqingbao');
			   sign = sign.toLowerCase();//将字符串大写转成小写               
           var url = server_url+'r=datas/setPass&access_token='+access_token+'&admin_id='+admin_id+'&message_id='+message_id+'&v=1.0&sign='+sign;            
               api.ajax({
			            url: url,
			            method: 'get',
			            cache: false,
			            timeout: 30,			
			            dataType: 'json'
		       }, function(ret, err){ 
		                api.toast({
				            msg: ret.message,
                            duration:2000,
                            location: 'middle'
                        }); 
                        if(ret.success == "101"){
                             setTimeout(function(){api.closeFrame({name: 'operationFrame'});},1000);  
                        } 
		       });		   		 
    }


/***打开报告详情
 * *
 * */
 
    function openfile(message_id){
             api.showProgress({
			      style: 'default',
			      animationType: 'fade',
			      title: '',
			      text: '',
			      modal: true
			 });

            //获取验证接口的值access_token、admin_id以及当前页码
	        var access_token = $("#access_token").val();                     
		    var admin_id = $("#admin_id").val();  
		    var sign = faultylabs.MD5(access_token+admin_id+message_id+'datas/getMsg1.0syjqingbao');
			    sign = sign.toLowerCase();//将字符串大写转成小写
            var url = server_url+'r=datas/getMsg&access_token='+access_token+'&admin_id='+admin_id+'&message_id='+message_id+'&v=1.0&sign='+sign;                                  

      		api.ajax({
			         url: url,
			         method: 'get',
			         cache: false,
			         timeout: 30,			
			         dataType: 'json'
		       }, function(ret, err){
		       		 
		             if (ret) {		
			              if(ret.success == "100"){//如果返回数据成功，则判断本地是否存在该文件，文件是以id命名
			              		
								var t_name = ret.id;
								var t_url = ret.upfile_path;
								
								var tmpFile = Alpe_getLocalStorge(t_name)
								if(''==tmpFile||null==tmpFile||undefined==tmpFile){
									api.confirm({
						                 title: '下载提醒',
						                 msg: '文件不在本地是否需要下载?',
						                 buttons:['确定', '取消']
						             },function(ret,err){
						                 if(ret.buttonIndex == 1){
						                       api.download({
											    url: t_url,
											    savePath: 'fs://testDown/'+t_name+'.pdf',
											    report: true,
											    cache: true,
											    allowResume:true
											},function(ret,err){
											    if (1==ret.state) {
											    	 
											    	Alpe_setLocalStorge(t_name,ret.savePath);
											        var obj = api.require('pdfReader');
									                obj.open({
									                      path:ret.savePath
									                }); 
											    } 
											    if (2==ret.state) {
											        alert(err.msg);
											    } 
											});
						                 }
						             });
								}else{
									var obj = api.require('pdfReader');
						     		obj.open({
						           		path:tmpFile
						        	});
								}
							api.hideProgress(); 	
                          }else{
                          
                                api.toast({
				                    msg: ret.message,
                                    duration:3000,
                                    location: 'middle'
                                });
                                api.hideProgress(); 
                          }
 			         }else{
			              api.toast({
				               msg: '数据请求错误，请重新登录！',
                               duration:3000,
                               location: 'bottom'
                          });
                          api.hideProgress(); 
                          
			         } 			               			                  
		       });    		                                 
    }


/***下载查看报告
 * *
 * */
 
    function downfile(url,name){
           api.download({
                  url: url,
                  savePath: 'fs://'+name+'.pdf',
                  report: true,
                  cache: true,
                  bounces: false,
                  allowResume:true
           },function(ret,err){  
                  if(state == "1"){
                      openPdf(name);
                  }else{
                      api.alert({msg:"11111111111"});
                  }
                
           });                                     					 
    }
 

   function openPdf(name){
          var obj = api.require('pdfReader');
              obj.open({
                     path:'fs://'+name+'.pdf',
              });
   }
 

 

 
 
 





 